<?php

namespace App\Middleware\Auth;


use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Hyperf\HttpServer\Contract\ResponseInterface as HttpResponse;

use Qbhy\HyperfAuth\Guard\JwtGuard;


class UserAuthMiddleware implements MiddlewareInterface
{

    #[Inject]
    protected HttpResponse $response;

    #[Inject]
    protected JwtGuard $jwtGuard;

    public function __construct(protected ContainerInterface $container, HttpResponse $response, JwtGuard $jwtGuard)
    {
        $this->response = $response;

        $this->jwtGuard = $jwtGuard;
    }

    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {

        $this->jwtGuard->user();

        return $handler->handle($request);

    }

}